package rmmk.framework.gui.similarityMeasureSelection;

import java.awt.GridLayout;
import java.util.ArrayList;

import javax.swing.JPanel;

import rmmk.algorithms.similarityMeasures.NgramMeasure;
import rmmk.algorithms.similarityMeasures.SimilarityMeasureManager;
import rmmk.algorithms.similarityMeasures.TermFrequencyMatrix;
import rmmk.algorithms.similarityMeasures.abstraction.AbstractSimilarityMeasure;

public class SimilarityMeasurePanel extends JPanel{
		
		private static final long serialVersionUID = 1L;

		NgramPanel nGramPanel;
		TermFrequencyMatrixPanel tfmPanel;
		//KarpRabinPanel krPanel;
		
		public SimilarityMeasurePanel(SimilarityMeasureManager smm) {
		super();
		
		setLayout(new GridLayout(5,1,0,5));
		nGramPanel = new NgramPanel();
		add(nGramPanel);

		tfmPanel = new TermFrequencyMatrixPanel();
		add(tfmPanel);
		
		//krPanel = new KarpRabinPanel();
		//add(krPanel);
		}
		
		public ArrayList<AbstractSimilarityMeasure> getSimilarityMeasures() {
			ArrayList<AbstractSimilarityMeasure> sims = new ArrayList<AbstractSimilarityMeasure>();

			if (nGramPanel.getSimilarityMeasure() != null) {
				ArrayList<String> limits = nGramPanel.getSimilarityMeasure();
				AbstractSimilarityMeasure ngramMeasure = new NgramMeasure(Integer.parseInt(limits.get(0)),Integer.parseInt(limits.get(1)));
				sims.add(ngramMeasure);								
			}
			if (tfmPanel.getSimilarityMeasure() != null) {

				sims.add(new TermFrequencyMatrix(Integer.parseInt(tfmPanel.getSimilarityMeasure().get(0))));
			}

			return sims;
		}

}
